package com.grass.cropTradingCenter.controller.user;

import com.grass.cropTradingCenter.common.Result;
import com.grass.cropTradingCenter.pojo.entity.UserCommit;
import com.grass.cropTradingCenter.service.UserCommitService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/user/commit")
@Api(tags = "用户 -- 评论接口")
public class CommitController {
    @Autowired
    UserCommitService userCommitService;


    @PostMapping("/create/commit")
    @ApiOperation("提交评论")
    public Result createCommit(@RequestBody UserCommit commit) {
        userCommitService.createCommit(commit);
        return Result.success();
    }

    @GetMapping("/commitList")
    @ApiOperation("评论列表")
    public Result<List<UserCommit>> commitList() {
        return Result.success(userCommitService.commitList());
    }

    @GetMapping("/commitList/{id}")
    @ApiOperation("商品评论列表")
    public Result<List<UserCommit>> commitListByGoodsId(@PathVariable("id") Integer id) {
        return Result.success(userCommitService.commitList(id));
    }

}
